import { reqgetCategoryList, reqGetBannerList ,reqGetfloorList} from '@/api/index';

let state = {
    categoryList: [],
    /* 轮播图的数据 */
    bannerList: [],
    floorList:[]
};

let mutations = {
    CATEGORYLIST(state, categoryList) {
        state.categoryList = categoryList;
    },
    GETBANNERLIST(state, bannerList) {
        state.bannerList = bannerList;
    },
    GETFLOORLIST(state, floorList) {
        state.floorList = floorList;
    }

};

let actions = {
    async categoryList({ commit }) {
        let result = await reqgetCategoryList();
        if (result.code == 200) {
            sessionStorage.setItem("categoryList",JSON.stringify(result.data));
            commit('CATEGORYLIST', result.data);
        }
    },
    async getBannerList({ commit }) {
        let result = await reqGetBannerList();
        if (result.code == 200) {
            commit('GETBANNERLIST',result.data);
        }

    },
    async getFloorList({ commit }) {
        let result = await reqGetfloorList();
        if (result.code == 200) {
            commit('GETFLOORLIST',result.data);
        }
    }
};

let getters = {

};

export default {
    state,
    mutations,
    actions,
    getters
}

